home *** CD-ROM | disk | FTP | other *** search
- Path: news.umbc.edu!not-for-mail
- From: schlein@umbc.edu (Jonas J. Schlein)
- Newsgroups: comp.lang.c
- Subject: Re: a typedef question
- Date: 21 Mar 1996 13:56:42 -0500
- Organization: University of Maryland Baltimore County
- Distribution: us
- Message-ID: <4is8pa$rnd@umbc9.umbc.edu>
- References: <4ilq55$4oo@newserv.ksu.ksu.edu> <4is8hu$rc4@umbc9.umbc.edu>
- NNTP-Posting-Host: umbc9.umbc.edu
- NNTP-Posting-User: schlein
-
- Bin Chen <binchen@phys.ksu.edu> wrote:
- |> Here is the question:
- |>
- |> typedef struct A {
- |> ......
- |> struct B one_attr;
- |> ......
- |> };
- |>
- |> typedef struct B {
- |> ......
- |> struct A two_attr;
- |> ......
- |> };
- |>
- |> Is this OK? How do you make it correct if it is not right?
-
- Actually it's not right...I can't see why you are using typedef when
- no alias is being attributed to your struct names. Get rid of those
- keywords and you should be ok. Otherwise, choose an appropriate alternate
- identifier for your structures.
-
- Also your structures contain each other mutually which will cause
- infinite recursion if such a thing could ever exist. Perhaps what you
- want is pointers to structures?
-
- I'd try the following:
-
- struct A
- {
- struct B * one_attr;
- };
-
- struct B
- {
- struct A * two_attr;
- };
- --
- "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
-
- Jonas J. Schlein (schlein@gl.umbc.edu)
-